<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    window.onload = function () {
        function fn() {
            let a = 2
            function add() {
                a++
                console.log(a)
            }

            function minus() {
                a--
                console.log(a)
            }

            return {add, minus}
        }

        fn().add()//3
        fn().minus()//1

        let fn1 = fn()
        fn1.add()//3
        fn1.minus()//2
    }

</script>
</html>
